package com.mm.statics;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author 杨朝湖
 * @ClassName: CodeMsg
 * @Description: 异常返回参数定义
 * @date 2020-11-05 09:35:36
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CodeMsg {

    private int code;
    private String msg;
    /**
     * 绑定异常，用于自定义返回的提示信息
     */
    public static CodeMsg BIND_ERROR = new CodeMsg(500101, "%s");

    /**
     * 返回带参数的错误码
     *
     * @param args
     * @return
     */
    public CodeMsg fillArgs(Object... args) {
        int code = this.code;
        String message = String.format(this.msg, args);
        return new CodeMsg(code, message);
    }
}
